/*--------------------------------------------------------------------------------
 * $B%*%V%8%'%/%H$N4IM}(B($B<g$K:FMxMQ@-$N$"$k%a%b%j4IM}(B)
 *
 * ===Copyright===
 * Copyright (C) 2005-2006, 2008 toge (toge.mail@gmail.com)
 * (See Copyright Notice at COPYRIGHT file)
 *
 * ===Licence===
 * Mit License
 *
 * ===Revision===
 * $Revision: 203 $
 -------------------------------------------------------------------------------*/
#include <boost/preprocessor.hpp>

#if !BOOST_PP_IS_ITERATING

#include "ObjectContainer.h"

/**
 * $BCF$N@8@.!&:FMxMQ$N4IM}(B
 *
 */
class BOOST_PP_CAT(OBJECT_NAME, Manager)
{
  /* $B30ItDj5A%7!<%1%s%9(BBULLET_TYPES$B$N3FMWAGMQ$NDj5A$r<B9T$9$k(B */
#  define BOOST_PP_ITERATION_PARAMS_1 (4, (0, BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(OBJECT_TYPES)), \
                                           "ObjectManager.h", OBJECT_TYPES))
#  include BOOST_PP_ITERATE()

#endif // !BOOST_PP_IS_ITERATING

  /*****************************************************
   * $B30ItDj5A%7!<%1%s%9(BBULLET_TYPES$B$NMWAG?t%k!<%W(B begin
   */
#if BOOST_PP_IS_ITERATING

  /* $BCF$N7?(B */
#  define TARGET_TYPE__ BOOST_PP_SEQ_ELEM(BOOST_PP_ITERATION(), \
                                          BOOST_PP_APPLY(BOOST_PP_ITERATION_FLAGS()))

  /* $BCF$r3JG<$9$k%3%s%F%J$NL>A0(B */
#  define CONTAINER_NAME__ BOOST_PP_CAT(BOOST_PP_CAT(bulletContainer, TARGET_TYPE__), _)

  /* $BCF$r3JG<$9$k%3%s%F%J$N7?(B */
#  define CONTAINER_TYPE__ BOOST_PP_CAT(TARGET_TYPE__, Container)

public:
  /* $BCF$r3JG<$9$k%3%s%F%J$N7?Dj5A(B */
  typedef objectpool< TARGET_TYPE__ > CONTAINER_TYPE__;

private:
  /* $BCF$r3JG<$9$k%3%s%F%J$NDj5A(B */
  CONTAINER_TYPE__ CONTAINER_NAME__;

public:
  /**
   * $BCF$rDI2C$9$k(B
   * @param bullet $BDI2C$9$kCF(B
   */
  TARGET_TYPE__& BOOST_PP_CAT(create, TARGET_TYPE__)() {return CONTAINER_NAME__.create();}

  /**
   * $BCF$r:o=|$9$k(B
   * @param bullet $B:o=|$9$kCF(B
   */
  void kill(TARGET_TYPE__& bullet) {CONTAINER_NAME__.kill(bullet);}

  /**
   * $BCF$rA4:o=|$9$k(B
   */
  void BOOST_PP_CAT(kill, TARGET_TYPE__)() {CONTAINER_NAME__.killAll();}

  /**
   * $BCF$N8D?t$rJV$9(B
   * @return $BCF$N?t(B
   */
  CONTAINER_TYPE__::size_type BOOST_PP_CAT(size, TARGET_TYPE__)() const
  {
    return CONTAINER_NAME__.size();
  }

  /**
   * $B%$%F%l!<%?<hF@(B
   */
  CONTAINER_TYPE__::iterator BOOST_PP_CAT(begin, TARGET_TYPE__)()
  {
    return CONTAINER_NAME__.begin();
  }

  CONTAINER_TYPE__::iterator BOOST_PP_CAT(end, TARGET_TYPE__)()
  {
    return CONTAINER_NAME__.end();
  }

  CONTAINER_TYPE__::const_iterator BOOST_PP_CAT(begin, TARGET_TYPE__)() const
  {
    return CONTAINER_NAME__.begin();
  }

  CONTAINER_TYPE__::const_iterator BOOST_PP_CAT(end, TARGET_TYPE__)() const
  {
    return CONTAINER_NAME__.end();
  }

#  undef CONTAINER_TYPE__
#  undef CONTAINER_NAME__
#  undef TARGET_TYPE__

#endif // BOOST_PP_IS_ITERATING
  /*
   * $B30ItDj5A%7!<%1%s%9(BBULLET_TYPES$B$NMWAG?t%k!<%W(B end
   *******************************************************/


  /* $B%k!<%W0J30$N=hM}(B begin */
#if !BOOST_PP_IS_ITERATING
//#  define BOOST_PP_CAT(OBJECT_NAME, MANAGER__H_)

public:
  /*
   * $BA4$F$NCF$r:o=|$9$k(B
   */
  void killAll()
  {
#define GEN_KILLALLBULLETS(r, p, elem)  BOOST_PP_CAT(BOOST_PP_CAT(bulletContainer, elem), _).killAll();
    BOOST_PP_SEQ_FOR_EACH(GEN_KILLALLBULLETS, _, OBJECT_TYPES)
  }
};

#undef OBJECT_TYPES
#undef OBJECT_NAME

#endif // !BOOST_PP_IS_ITERATING && !defined(BOOST_PP_CAT(OBJECT_NAME, MANAGER__H_))
  /* $B%k!<%W0J30$N=hM}(B end */
